package com.delivery.service.impl;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import com.delivery.service.ICategoriesContent;
import com.delivery.utils.StringUtils;

public class CategoriesContentService implements ICategoriesContent{
	

	public String getCategoriesContents(String url) throws Exception{
		if(url == null){
			return null;
		}
		if(StringUtils.isEmpty(url)){
			return null;
		}
		HttpGet httpGet = new HttpGet(String.valueOf(url));
		//httpGet.setParams(params);
		HttpClient httpClient = new DefaultHttpClient();
		try {
			HttpResponse httpResponse = httpClient.execute(httpGet);
			if(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
				return EntityUtils.toString(httpResponse.getEntity());
			} else {
				return "";
			}
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}

	public String getToken() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
}
